package com.shaomengjie.smjmvp.presenter;

import com.shaomengjie.smjmvp.bean.UserBean;
import com.shaomengjie.smjmvp.contract.LoginContract;
import com.shaomengjie.smjmvp.retrofit.LoginServers;
import com.shaomengjie.smjmvp.retrofit.utils.BaseSubscriber;
import com.shaomengjie.smjmvp.view.core.BaseActivity;

/**
 * Created by shaomengjie on 2017/4/7.
 * pdsshaomengjie@live.com
 */

public class LoginPresenter implements LoginContract.Presenter{
    LoginContract.View view;
    public LoginPresenter( LoginContract.View view){
        this.view = view;
        view.setPresenter(this);
    }


    @Override
    public void requestLogion(String username, String password, BaseActivity context) {
        LoginServers.requestLogion(username, password, new BaseSubscriber<UserBean>(context) {
            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(UserBean userBean) {
                view.showText(userBean);
            }
        });
    }
}
